using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMType_VehicleController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMType_Vehicle()
        {
            return cls.BindGridData("sp_TMType_Vehicle");
        }
        public DataTable BindGirdTMType_Vehicle_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMType_Vehicle_Detail_Edit", "@Type_Vehicle_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMType_Vehicle(clsTMType_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Type_Unit_Vehicle_ID", data.Type_Unit_Vehicle_ID);
            cls.AddParameter("@Type_Vehicle_Alias", data.Type_Vehicle_Alias);
            cls.AddParameter("@Type_Vehicle_Name", data.Type_Vehicle_Name);
            cls.AddParameter("@Type_Vehicle_Number_Of_Seats", data.Type_Vehicle_Number_Of_Seats);
            cls.AddParameter("@Type_Number_Of_Vehicles", data.Type_Number_Of_Vehicles);
            cls.ExecuteNonQuery("sp_TMType_Vehicle_Insert");
            return true;
        }
        public bool UpdateTMType_Vehicle(clsTMType_VehicleProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Type_Vehicle_ID", data.Type_Vehicle_ID);
            cls.AddParameter("@Type_Unit_Vehicle_ID", data.Type_Unit_Vehicle_ID);
            cls.AddParameter("@Type_Vehicle_Alias", data.Type_Vehicle_Alias);
            cls.AddParameter("@Type_Vehicle_Name", data.Type_Vehicle_Name);
            cls.AddParameter("@Type_Vehicle_Number_Of_Seats", data.Type_Vehicle_Number_Of_Seats);
            cls.AddParameter("@Type_Number_Of_Vehicles", data.Type_Number_Of_Vehicles);
            cls.ExecuteNonQuery("sp_TMType_Vehicle_Update");
            return true;
        }
        public bool DeleteTMType_Vehicle(int id)
        {
            cls.Delete("sp_TMType_Vehicle_Delete", "@Type_Vehicle_ID", id);
            return true;
        }
        public bool TMType_Vehicle_Check_Delete_TMVehicle(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMType_Vehicle_Check_Delete_TMVehicle", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMType_Vehicle_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}